import request from '@/utils/request'

const api = {
  page: '/system/user/page',
  systemUser: '/system/user',
  systemRole: '/system/role/list',
  importUser: '/system/user/importUser'
}

export function getSystemUser (parameter) {
  return request({
    url: api.page,
    method: 'get',
    params: parameter
  })
}

export function getSystemRole (parameter) {
  return request({
    url: api.systemRole,
    method: 'get',
    params: parameter
  })
}

export function saveSystemUser (parameter) {
  return request({
    url: api.systemUser,
    method: parameter.userId === 0 ? 'post' : 'put',
    data: parameter
  })
}

export function deleteSystemUser (parameter) {
  return request({
    url: api.systemUser + `/${parameter.id}`,
    method: 'delete'
  })
}
export function importUserTable (parameter) {
  return request({
    url: api.importUser,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: parameter
  })
}
